package org.jsola.hr.service.impl;

import com.alibaba.fastjson.JSONObject;
import org.jsola.core.Page;
import org.jsola.hr.common.ExampleKit;
import org.jsola.hr.constant.HrConstants;
import org.jsola.hr.dao.ICompanyEmpInfoRequireDAO;
import org.jsola.hr.dto.*;
import org.jsola.hr.entity.CompanyDO;
import org.jsola.hr.entity.CompanyEmpInfoRequireDO;
import org.jsola.hr.exception.HrException;
import org.jsola.hr.query.CompanyEmpInfoRequireQuery;
import org.jsola.hr.service.*;
import org.jsola.hr.vo.*;
import org.jsola.user.core.TokenUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import tk.mybatis.mapper.entity.Example;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * @author zhr
 */
@Service("hrCompanyEmpInfoRequireServiceImpl")
public class CompanyEmpInfoRequireServiceImpl implements ICompanyEmpInfoRequireService {

    @Autowired
    private ICompanyEmpInfoRequireDAO companyEmpInfoRequireDAO;

    @Autowired
    private ICompanyService companyService;

    @Autowired
    private IEmpContactsRequireService contactsRequireService;

    @Autowired
    private IEmpWorkRequireService workRequireService;

    @Autowired
    private IEmpEducationRequireService educationRequireService;

    @Autowired
    private IEmpCardRequireService cardRequireService;

    @Autowired
    private IEmpTrainRequireService trainRequireService;

    @Autowired
    private IEmpCertificateRequireService certificateRequireService;

    @Override
    @Transactional(value = HrConstants.TX, rollbackFor = Exception.class)
    public CompanyEmpInfoRequireVO save(CompanyEmpInfoRequireAddDTO companyEmpInfoRequireAddDTO, TokenUser tokenUser) {
        // 转DO
        CompanyEmpInfoRequireDO companyEmpInfoRequireDO = companyEmpInfoRequireAddDTO.to(CompanyEmpInfoRequireDO.class);

        CompanyEmpInfoRequireVO requireVO = findByCompanyAndType(
                companyEmpInfoRequireAddDTO.getCompanyId(),
                companyEmpInfoRequireAddDTO.getType(),
                tokenUser.getSiteId());

        if (Objects.isNull(requireVO)) {
            // 保存
            companyEmpInfoRequireDO = save(companyEmpInfoRequireDO, tokenUser.getSiteId(), tokenUser.getUserId());
            return companyEmpInfoRequireDO.to(CompanyEmpInfoRequireVO.class);
        } else {
            companyEmpInfoRequireDO.setId(requireVO.getId());
            //根据主键更新，只更新非null值
            updateByIdSelective(companyEmpInfoRequireDO, tokenUser.getSiteId(), tokenUser.getUserId());
            return selectById(requireVO.getId(), tokenUser.getSiteId());
        }
    }

    @Override
    @Transactional(value = HrConstants.TX, rollbackFor = Exception.class)
    public int update(CompanyEmpInfoRequireUpdateDTO companyEmpInfoRequireUpdateDTO, TokenUser tokenUser) {
        //转DO
        CompanyEmpInfoRequireDO companyEmpInfoRequireDO = companyEmpInfoRequireUpdateDTO.to(CompanyEmpInfoRequireDO.class);
        //根据主键更新，只更新非null值
        return updateByIdSelective(companyEmpInfoRequireDO, tokenUser.getSiteId(), tokenUser.getUserId());
    }

    @Override
    @Transactional(value = HrConstants.TX, rollbackFor = Exception.class)
    public int deleteByIds(TokenUser tokenUser, String... companyEmpInfoRequireIds) {
        return logicalDeleteByIds(tokenUser.getSiteId(), tokenUser.getUserId(), (Object[]) companyEmpInfoRequireIds);
    }


    @Override
    public CompanyEmpInfoRequireVO selectById(String companyEmpInfoRequireId, String siteId) {
        CompanyEmpInfoRequireDO companyEmpInfoRequireDO = selectDOById(companyEmpInfoRequireId, siteId);
        if (companyEmpInfoRequireDO == null) {
            return null;
        }
        return companyEmpInfoRequireDO.to(CompanyEmpInfoRequireVO.class);
    }

    @Override
    public List<CompanyEmpInfoRequireListVO> select(CompanyEmpInfoRequireQuery companyEmpInfoRequireQuery, String siteId) {
        List<CompanyEmpInfoRequireDO> companyEmpInfoRequireDOList = selectDO(companyEmpInfoRequireQuery, siteId);
        if(CollectionUtils.isEmpty(companyEmpInfoRequireDOList)) {
            return companyEmpInfoRequireDOList == null ? null : new ArrayList<>();
        }
        return companyEmpInfoRequireDOList.stream()
                .map(companyEmpInfoRequireDO -> companyEmpInfoRequireDO.to(CompanyEmpInfoRequireListVO.class))
                .collect(Collectors.toList());
    }

    @Override
    public int selectCount(CompanyEmpInfoRequireQuery companyEmpInfoRequireQuery, String siteId) {
        Example example = buildExample(companyEmpInfoRequireQuery,siteId);
        return companyEmpInfoRequireDAO.selectCountByExample(example);
    }

    @Override
    public Page<CompanyEmpInfoRequireListVO> selectPage(CompanyEmpInfoRequireQuery companyEmpInfoRequireQuery, String siteId) {
        Example example = buildExample(companyEmpInfoRequireQuery,siteId);
        Page<CompanyEmpInfoRequireDO> page = companyEmpInfoRequireDAO.selectPageByExample(example,
                companyEmpInfoRequireQuery.getPageNo(),
                companyEmpInfoRequireQuery.getPageSize());

        return page.to(CompanyEmpInfoRequireListVO.class);
    }

    @Override
    public CompanyEmpInfoRequireDO selectDOById(String companyEmpInfoRequireId, String siteId) {
        return listById(companyEmpInfoRequireId, siteId);
    }

    @Override
    public List<CompanyEmpInfoRequireDO> selectDO(CompanyEmpInfoRequireQuery companyEmpInfoRequireQuery, String siteId) {
        Example example = buildExample(companyEmpInfoRequireQuery,siteId);
        return companyEmpInfoRequireDAO.selectByExample(example);
    }

    @Override
    @Transactional(value = HrConstants.TX, rollbackFor = Exception.class)
    public CompanyEmpAllInfoRequireVO findByCompanyId(String companyId, String type, TokenUser tokenUser) {
        CompanyEmpInfoRequireVO requireVO = findByCompanyAndType(companyId, type, tokenUser.getSiteId());
        if (Objects.isNull(requireVO)) {
            // 没有且公司存在,新增一条
            CompanyDO company = companyService.selectDOById(companyId, tokenUser.getSiteId());
            if (Objects.isNull(company)) {
                return null;
            }
            CompanyEmpInfoRequireAddDTO requireAddDTO = new CompanyEmpInfoRequireAddDTO();
            requireAddDTO.setCompanyId(companyId);
            requireAddDTO.setType(type);
            requireVO = save(requireAddDTO, tokenUser);
        }

        // 添加关联信息的字段控制
        return addRelationRequire(requireVO, tokenUser);
    }

    /**
     * 获取员工关联信息的字段必填等
     *
     * @param requireVO 员工信息字段需求方式
     * @param tokenUser 当前用户
     * @return 员工信息字段及员工关联信息需求方式
     */
    private CompanyEmpAllInfoRequireVO addRelationRequire(CompanyEmpInfoRequireVO requireVO, TokenUser tokenUser) {
        if (Objects.isNull(requireVO)) {
            return null;
        }
        // 公司
        String companyId = requireVO.getCompanyId();
        // 场景
        String requireType = requireVO.getType();

        CompanyEmpAllInfoRequireVO allInfoRequireVO = requireVO.to(CompanyEmpAllInfoRequireVO.class);
        // 公司员工联系人所需信息
        EmpContactsRequireVO empContactsRequireVO = contactsRequireService.selectByCompanyAndType(companyId, requireType, tokenUser);

        // 公司员工工作经历所需信息
        EmpWorkRequireVO empWorkRequireVO = workRequireService.selectByCompanyAndType(companyId, requireType, tokenUser);

        // 公司员工教育经历所需信息
        EmpEducationRequireVO empEducationRequireVO = educationRequireService.selectByCompanyAndType(companyId, requireType, tokenUser);

        // 公司员工证件信息所需信息
        EmpCardRequireVO empCardRequireVO = cardRequireService.selectByCompanyAndType(companyId, requireType, tokenUser);

        // 公司员工培训记录所需信息
        EmpTrainRequireVO empTrainRequireVO = trainRequireService.selectByCompanyAndType(companyId, requireType, tokenUser);

        // 公司员工证书所需信息
        EmpCertificateRequireVO empCertificateRequireVO = certificateRequireService.selectByCompanyAndType(companyId, requireType, tokenUser);

        allInfoRequireVO.setEmpContactsRequireVO(empContactsRequireVO);
        allInfoRequireVO.setEmpWorkRequireVO(empWorkRequireVO);
        allInfoRequireVO.setEmpEducationRequireVO(empEducationRequireVO);
        allInfoRequireVO.setEmpCardRequireVO(empCardRequireVO);
        allInfoRequireVO.setEmpTrainRequireVO(empTrainRequireVO);
        allInfoRequireVO.setEmpCertificateRequireVO(empCertificateRequireVO);

        return allInfoRequireVO;
    }

    /**
     * 根据公司id和类型查询
     *
     * @param companyId 公司id
     * @param type      类型
     * @param siteId    站点id
     * @return 用户信息限制
     */
    private CompanyEmpInfoRequireVO findByCompanyAndType(String companyId, String type, String siteId) {
        Example example = new Example(CompanyEmpInfoRequireDO.class);
        example.and()
                .andEqualTo("companyId", companyId)
                .andEqualTo("type", type)
                .andEqualTo("valid", true)
                .andEqualTo("siteId", siteId);
        CompanyEmpInfoRequireDO requireDO = companyEmpInfoRequireDAO.selectOneByExample(example);
        if (Objects.isNull(requireDO)) {
            return null;
        }
        return requireDO.to(CompanyEmpInfoRequireVO.class);
    }

    @Override
    @Transactional(value = HrConstants.TX, rollbackFor = Exception.class)
    public int updateInfoRequireById(String id, String code, Integer value, String siteId) {
        // 要修改的值
        JSONObject object = new JSONObject();
        object.put(code, value);
        // 条件
        Example example = new Example(CompanyEmpInfoRequireDO.class);
        example.and()
                .andEqualTo("id", id)
                .andEqualTo("valid", true)
                .andEqualTo("siteId", siteId);

        // 转实体
        CompanyEmpInfoRequireDO up = JSONObject.parseObject(object.toJSONString(), CompanyEmpInfoRequireDO.class);
        return companyEmpInfoRequireDAO.updateByExampleSelective(up, example);
    }

    @Override
    @Transactional(value = HrConstants.TX, rollbackFor = Exception.class)
    public int updateInfoRequireByCompanyId(String companyId, String type, String code, Integer value, String siteId) {
        Example example = new Example(CompanyEmpInfoRequireDO.class);
        example.and()
                .andEqualTo("type", type)
                .andEqualTo("valid", true)
                .andEqualTo("siteId", siteId);
        if (!"all".equals(companyId)) {
            example.and().andEqualTo("companyId", companyId);
        }

        // 要修改的值
        JSONObject object = new JSONObject();
        object.put(code, value);
        // 转实体
        CompanyEmpInfoRequireDO up = JSONObject.parseObject(object.toJSONString(), CompanyEmpInfoRequireDO.class);
        return companyEmpInfoRequireDAO.updateByExampleSelective(up, example);
    }

    @Override
    @Transactional(value = HrConstants.TX, rollbackFor = Exception.class)
    public int updateRalation(CompanyAllEmpInfoRequireUpdateDTO requireUpdateDTO, TokenUser tokenUser) {

        CompanyEmpInfoRequireVO requireVO = selectById(requireUpdateDTO.getId(), tokenUser.getSiteId());
        if (Objects.isNull(requireVO)) {
            throw new HrException("公司员工所需填写信息不存在或已删除");
        }
        // 修改员工信息
        //转DO
        CompanyEmpInfoRequireDO companyEmpInfoRequireDO = requireUpdateDTO.to(CompanyEmpInfoRequireDO.class);
        //根据主键更新，只更新非null值
        int upCount = updateByIdSelective(companyEmpInfoRequireDO, tokenUser.getSiteId(), tokenUser.getUserId());

        // 公司员工联系人所需信息
        int upCount1 = updateContactsRequire(requireUpdateDTO.getContactsRequireUpdateDTO(), tokenUser);

        // 公司员工工作经历所需信息
        int upCount2 = updateWorkRequire(requireUpdateDTO.getWorkRequireUpdateDTO(), tokenUser);

        // 公司员工教育经历所需信息
        int upCount3 = updateEducationRequire(requireUpdateDTO.getEducationRequireUpdateDTO(), tokenUser);

        // 公司员工证件信息所需信息
        int upCount4 = updateCardRequire(requireUpdateDTO.getCardRequireUpdateDTO(), tokenUser);

        // 公司员工培训记录所需信息
        int upCount5 = updateTrainRequire(requireUpdateDTO.getTrainRequireUpdateDTO(), tokenUser);

        // 公司员工证书所需信息
        int upCount6 = updateCertificateRequire(requireUpdateDTO.getCertificateRequireUpdateDTO(), tokenUser);

        int allCount = upCount + upCount1 + upCount2 + upCount3 + upCount4 + upCount5 + upCount6;
        return allCount > 0 ? 1 : 0;
    }

    /**
     * 公司员工联系人所需信息
     *
     * @param contactsRequireUpdateDTO 员工联系人所需信息
     * @param tokenUser                当前用户
     * @return 修改数量
     */
    private int updateContactsRequire(EmpContactsRequireUpdateDTO contactsRequireUpdateDTO, TokenUser tokenUser) {
        if (Objects.isNull(contactsRequireUpdateDTO)) {
            return 0;
        }
        return contactsRequireService.update(contactsRequireUpdateDTO, tokenUser);
    }

    /**
     * 公司员工联系人所需信息
     *
     * @param workRequireUpdateDTO 员工联系人所需信息
     * @param tokenUser            当前用户
     * @return 修改数量
     */
    private int updateWorkRequire(EmpWorkRequireUpdateDTO workRequireUpdateDTO, TokenUser tokenUser) {
        if (Objects.isNull(workRequireUpdateDTO)) {
            return 0;
        }
        return workRequireService.update(workRequireUpdateDTO, tokenUser);
    }

    /**
     * 公司员工教育经历所需信息
     *
     * @param educationRequireUpdateDTO 员工教育经历所需信息
     * @param tokenUser                 当前用户
     * @return 当前用户
     */
    private int updateEducationRequire(EmpEducationRequireUpdateDTO educationRequireUpdateDTO, TokenUser tokenUser) {
        if (Objects.isNull(educationRequireUpdateDTO)) {
            return 0;
        }
        return educationRequireService.update(educationRequireUpdateDTO, tokenUser);
    }

    /**
     * 公司员工证件信息所需信息
     *
     * @param cardRequireUpdateDTO 员工证件信息所需信息
     * @param tokenUser            当前用户
     * @return 修改数量
     */
    private int updateCardRequire(EmpCardRequireUpdateDTO cardRequireUpdateDTO, TokenUser tokenUser) {
        if (Objects.isNull(cardRequireUpdateDTO)) {
            return 0;
        }
        return cardRequireService.update(cardRequireUpdateDTO, tokenUser);
    }

    /**
     * 公司员工培训记录所需信息
     *
     * @param trainRequireUpdateDTO 培训记录所需信息
     * @param tokenUser             当前用户
     * @return 当前用户
     */
    private int updateTrainRequire(EmpTrainRequireUpdateDTO trainRequireUpdateDTO, TokenUser tokenUser) {
        if (Objects.isNull(trainRequireUpdateDTO)) {
            return 0;
        }
        return trainRequireService.update(trainRequireUpdateDTO, tokenUser);
    }

    /**
     * 公司员工证书所需信息
     *
     * @param certificateRequireUpdateDTO 证书所需信息
     * @param tokenUser                   当前用户
     * @return 修改条数
     */
    private int updateCertificateRequire(EmpCertificateRequireUpdateDTO certificateRequireUpdateDTO, TokenUser tokenUser) {
        if (Objects.isNull(certificateRequireUpdateDTO)) {
            return 0;
        }
        return certificateRequireService.update(certificateRequireUpdateDTO, tokenUser);
    }


    /**
     * 根据查询参数，构建example

     * @param companyEmpInfoRequireQuery 查询参数
     * @param siteId 所属站点id
     * @return example
     */
    private Example buildExample(CompanyEmpInfoRequireQuery companyEmpInfoRequireQuery, String siteId) {
        Example example = new Example(CompanyEmpInfoRequireDO.class);
        example.and()
                .andEqualTo("valid", true)
                .andEqualTo("siteId", siteId);
        if (companyEmpInfoRequireQuery.getCompanyId() != null) {
            example.and().andEqualTo("companyId", companyEmpInfoRequireQuery.getCompanyId());
        }
        if (companyEmpInfoRequireQuery.getType() != null) {
            example.and().andEqualTo("type", companyEmpInfoRequireQuery.getType());
        }
        if (companyEmpInfoRequireQuery.getNumber() != null) {
            example.and().andEqualTo("number", companyEmpInfoRequireQuery.getNumber());
        }
        if (companyEmpInfoRequireQuery.getName() != null) {
            example.and().andEqualTo("name", companyEmpInfoRequireQuery.getName());
        }
        if (companyEmpInfoRequireQuery.getIdCard() != null) {
            example.and().andEqualTo("idCard", companyEmpInfoRequireQuery.getIdCard());
        }
        if (companyEmpInfoRequireQuery.getNation() != null) {
            example.and().andEqualTo("nation", companyEmpInfoRequireQuery.getNation());
        }
        if (companyEmpInfoRequireQuery.getBirthday() != null) {
            example.and().andEqualTo("birthday", companyEmpInfoRequireQuery.getBirthday());
        }
        if (companyEmpInfoRequireQuery.getGender() != null) {
            example.and().andEqualTo("gender", companyEmpInfoRequireQuery.getGender());
        }
        if (companyEmpInfoRequireQuery.getPhone() != null) {
            example.and().andEqualTo("phone", companyEmpInfoRequireQuery.getPhone());
        }
        if (companyEmpInfoRequireQuery.getEmail() != null) {
            example.and().andEqualTo("email", companyEmpInfoRequireQuery.getEmail());
        }
        if (companyEmpInfoRequireQuery.getEmpPhoto() != null) {
            example.and().andEqualTo("empPhoto", companyEmpInfoRequireQuery.getEmpPhoto());
        }
        if (companyEmpInfoRequireQuery.getHighestEducation() != null) {
            example.and().andEqualTo("highestEducation", companyEmpInfoRequireQuery.getHighestEducation());
        }
        if (companyEmpInfoRequireQuery.getMaritalStatus() != null) {
            example.and().andEqualTo("maritalStatus", companyEmpInfoRequireQuery.getMaritalStatus());
        }
        if (companyEmpInfoRequireQuery.getBirthStatus() != null) {
            example.and().andEqualTo("birthStatus", companyEmpInfoRequireQuery.getBirthStatus());
        }
        if (companyEmpInfoRequireQuery.getPoliticalStatus() != null) {
            example.and().andEqualTo("politicalStatus", companyEmpInfoRequireQuery.getPoliticalStatus());
        }
        if (companyEmpInfoRequireQuery.getPartyDate() != null) {
            example.and().andEqualTo("partyDate", companyEmpInfoRequireQuery.getPartyDate());
        }
        if (companyEmpInfoRequireQuery.getPartySite() != null) {
            example.and().andEqualTo("partySite", companyEmpInfoRequireQuery.getPartySite());
        }
        if (companyEmpInfoRequireQuery.getBirthplace() != null) {
            example.and().andEqualTo("birthplace", companyEmpInfoRequireQuery.getBirthplace());
        }
        if (companyEmpInfoRequireQuery.getNativeLocation() != null) {
            example.and().andEqualTo("nativeLocation", companyEmpInfoRequireQuery.getNativeLocation());
        }
        if (companyEmpInfoRequireQuery.getRegType() != null) {
            example.and().andEqualTo("regType", companyEmpInfoRequireQuery.getRegType());
        }
        if (companyEmpInfoRequireQuery.getCurrentLocation() != null) {
            example.and().andEqualTo("currentLocation", companyEmpInfoRequireQuery.getCurrentLocation());
        }
        if (companyEmpInfoRequireQuery.getEmerContact() != null) {
            example.and().andEqualTo("emerContact", companyEmpInfoRequireQuery.getEmerContact());
        }
        if (companyEmpInfoRequireQuery.getEmerPhone() != null) {
            example.and().andEqualTo("emerPhone", companyEmpInfoRequireQuery.getEmerPhone());
        }
        if (companyEmpInfoRequireQuery.getEmerLocation() != null) {
            example.and().andEqualTo("emerLocation", companyEmpInfoRequireQuery.getEmerLocation());
        }
        if (companyEmpInfoRequireQuery.getBankCard() != null) {
            example.and().andEqualTo("bankCard", companyEmpInfoRequireQuery.getBankCard());
        }
        if (companyEmpInfoRequireQuery.getBankName() != null) {
            example.and().andEqualTo("bankName", companyEmpInfoRequireQuery.getBankName());
        }
        if (companyEmpInfoRequireQuery.getBankPlace() != null) {
            example.and().andEqualTo("bankPlace", companyEmpInfoRequireQuery.getBankPlace());
        }
        if (companyEmpInfoRequireQuery.getSocType() != null) {
            example.and().andEqualTo("socType", companyEmpInfoRequireQuery.getSocType());
        }
        if (companyEmpInfoRequireQuery.getSocCard() != null) {
            example.and().andEqualTo("socCard", companyEmpInfoRequireQuery.getSocCard());
        }
        if (companyEmpInfoRequireQuery.getHealthCondition() != null) {
            example.and().andEqualTo("healthCondition", companyEmpInfoRequireQuery.getHealthCondition());
        }
        if (companyEmpInfoRequireQuery.getHasWeightyMedicalHis() != null) {
            example.and().andEqualTo("hasWeightyMedicalHis", companyEmpInfoRequireQuery.getHasWeightyMedicalHis());
        }
        if (companyEmpInfoRequireQuery.getJobTitle() != null) {
            example.and().andEqualTo("jobTitle", companyEmpInfoRequireQuery.getJobTitle());
        }
        if (companyEmpInfoRequireQuery.getJoinWorkDate() != null) {
            example.and().andEqualTo("joinWorkDate", companyEmpInfoRequireQuery.getJoinWorkDate());
        }
        if (companyEmpInfoRequireQuery.getWorkingUnitName() != null) {
            example.and().andEqualTo("workingUnitName", companyEmpInfoRequireQuery.getWorkingUnitName());
        }
        if (companyEmpInfoRequireQuery.getPutonghuaLevel() != null) {
            example.and().andEqualTo("putonghuaLevel", companyEmpInfoRequireQuery.getPutonghuaLevel());
        }
        if (companyEmpInfoRequireQuery.getSpeciality() != null) {
            example.and().andEqualTo("speciality", companyEmpInfoRequireQuery.getSpeciality());
        }
        if (companyEmpInfoRequireQuery.getPrizeWinning() != null) {
            example.and().andEqualTo("prizeWinning", companyEmpInfoRequireQuery.getPrizeWinning());
        }
        if (companyEmpInfoRequireQuery.getEnglishLevel() != null) {
            example.and().andEqualTo("englishLevel", companyEmpInfoRequireQuery.getEnglishLevel());
        }
        if (companyEmpInfoRequireQuery.getNcreLevel() != null) {
            example.and().andEqualTo("ncreLevel", companyEmpInfoRequireQuery.getNcreLevel());
        }
        if (companyEmpInfoRequireQuery.getTargetPost() != null) {
            example.and().andEqualTo("targetPost", companyEmpInfoRequireQuery.getTargetPost());
        }
        if (companyEmpInfoRequireQuery.getTabContacts() != null) {
            example.and().andEqualTo("tabContacts", companyEmpInfoRequireQuery.getTabContacts());
        }
        if (companyEmpInfoRequireQuery.getTabWork() != null) {
            example.and().andEqualTo("tabWork", companyEmpInfoRequireQuery.getTabWork());
        }
        if (companyEmpInfoRequireQuery.getTabEducation() != null) {
            example.and().andEqualTo("tabEducation", companyEmpInfoRequireQuery.getTabEducation());
        }
        if (companyEmpInfoRequireQuery.getTabCard() != null) {
            example.and().andEqualTo("tabCard", companyEmpInfoRequireQuery.getTabCard());
        }
        if (companyEmpInfoRequireQuery.getTabTrain() != null) {
            example.and().andEqualTo("tabTrain", companyEmpInfoRequireQuery.getTabTrain());
        }
        if (companyEmpInfoRequireQuery.getTabCertificate() != null) {
            example.and().andEqualTo("tabCertificate", companyEmpInfoRequireQuery.getTabCertificate());
        }
        if (companyEmpInfoRequireQuery.getAnnexIdCard() != null) {
            example.and().andEqualTo("annexIdCard", companyEmpInfoRequireQuery.getAnnexIdCard());
        }
        if (companyEmpInfoRequireQuery.getAnnexHousehold() != null) {
            example.and().andEqualTo("annexHousehold", companyEmpInfoRequireQuery.getAnnexHousehold());
        }
        if (companyEmpInfoRequireQuery.getAnnexDiploma() != null) {
            example.and().andEqualTo("annexDiploma", companyEmpInfoRequireQuery.getAnnexDiploma());
        }
        if (companyEmpInfoRequireQuery.getAnnexDegree() != null) {
            example.and().andEqualTo("annexDegree", companyEmpInfoRequireQuery.getAnnexDegree());
        }
        if (companyEmpInfoRequireQuery.getAnnexPractising() != null) {
            example.and().andEqualTo("annexPractising", companyEmpInfoRequireQuery.getAnnexPractising());
        }
        if (companyEmpInfoRequireQuery.getAnnexMajor() != null) {
            example.and().andEqualTo("annexMajor", companyEmpInfoRequireQuery.getAnnexMajor());
        }
        if (companyEmpInfoRequireQuery.getAnnexReward() != null) {
            example.and().andEqualTo("annexReward", companyEmpInfoRequireQuery.getAnnexReward());
        }
        if (companyEmpInfoRequireQuery.getAnnexNoCriminal() != null) {
            example.and().andEqualTo("annexNoCriminal", companyEmpInfoRequireQuery.getAnnexNoCriminal());
        }
        if (companyEmpInfoRequireQuery.getAnnexBlackWhitePhoto() != null) {
            example.and().andEqualTo("annexBlackWhitePhoto", companyEmpInfoRequireQuery.getAnnexBlackWhitePhoto());
        }
        if (companyEmpInfoRequireQuery.getAnnexPthLevel() != null) {
            example.and().andEqualTo("annexPthLevel", companyEmpInfoRequireQuery.getAnnexPthLevel());
        }
        if (companyEmpInfoRequireQuery.getAnnexEnglishLevel() != null) {
            example.and().andEqualTo("annexEnglishLevel", companyEmpInfoRequireQuery.getAnnexEnglishLevel());
        }
        if (companyEmpInfoRequireQuery.getAnnexNcreLevel() != null) {
            example.and().andEqualTo("annexNcreLevel", companyEmpInfoRequireQuery.getAnnexNcreLevel());
        }
        if (companyEmpInfoRequireQuery.getAnnexDrivingLicense() != null) {
            example.and().andEqualTo("annexDrivingLicense", companyEmpInfoRequireQuery.getAnnexDrivingLicense());
        }
        // 排序
        ExampleKit.setExampleOrder(example,companyEmpInfoRequireQuery.getOrders());
        return example;
    }
}




